﻿<%@ Page Language="C#" MasterPageFile="~/quickLMS.master" AutoEventWireup="true" CodeFile="ManageGroups.aspx.cs" Inherits="Admin_ManageGroups" Title="Manage Groups" %>
<%@ Register Assembly="Flan.Controls" Namespace="Flan.Controls" TagPrefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<asp:UpdatePanel ID="update1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
    <asp:GridView ID="grdGroups" runat="server" AutoGenerateColumns="false" SkinID="ROISkin">
        <Columns>
            <asp:BoundField DataField="GroupName" HeaderText="Group Name" />
            <asp:TemplateField HeaderText="Edit">
                <ItemTemplate>
                    <asp:LinkButton ID="lnkEdit" runat="server" Text="Edit" CommandArgument='<%# Eval("GroupID") %>' OnCommand="OpenEdit"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Delete">
                <ItemTemplate>
                    <asp:LinkButton ID="lnkDelete" runat="server" Text="Delete" CommandArgument='<%# Eval("GroupID") %>' OnCommand="DeleteGroup" OnClientClick="return confirm('Are you sure you want to delete this group?');"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Courses">
                <ItemTemplate>
                    <asp:Panel ID="pnlCourses" runat="server" OnPreRender="LoadCourses"></asp:Panel>
                    <asp:HiddenField ID="hidGroupID" runat="server" Value='<%# Eval("GroupID") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="Description" HeaderText="Description" />
            <asp:TemplateField HeaderText="Public">
                <ItemTemplate>
                    <asp:Label ID="lblPublic" runat="server" OnPreRender="CheckPublic" Text='<%# Eval("IsPublic") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <br />
    <asp:HiddenField ID="hidSelectedGroupID" runat="server" />
    <asp:LinkButton ID="lnkAddGroup" runat="server" Text="Add Group"></asp:LinkButton>
    <br />
    
    <ajax:ModalPopupExtender id="ModalPopup1" runat="server" 
    TargetControlID="lnkAddGroup"
    PopupControlID="pnlModal"
    CancelControlID="btnCancel"
    BackgroundCssClass="modalBackground"
    DropShadow="true"

></ajax:ModalPopupExtender>

<asp:panel ID="pnlModal" runat="server" CssClass="modalPopup" >
<asp:Panel ID="pnlDragTitle" runat="server" CssClass="modalHeader">
Add a New Group
</asp:Panel>
<br />
<table>
    <tr>
        <td>
            Group Name:
        </td>
        <td>
            <asp:TextBox ID="txtGroupName" runat="server"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td>
            Description:
        </td>
        <td>
            <asp:TextBox ID="txtDescription" runat="server" TextMode="MultiLine" Rows="5"></asp:TextBox>
        </td>
    </tr>
    <tr>
            <td>
                Public:
            </td>
            <td>
                <asp:CheckBox ID="cbPublic" runat="server" />
            </td>
        </tr>
    <tr>
        <td>
            Assign Courses:
        </td>
        <td>
            <div style="overflow: scroll; height: 300px;">
                <asp:CheckBoxList ID="cblAssignCourses" runat="server" DataTextField="CourseName" DataValueField="CourseID"></asp:CheckBoxList>
            </div>
        </td>
    </tr>
</table>

<asp:Button ID="btnAddNew" runat="server" OnClick="AddGroup" Text="Add Group" />
<asp:Button ID="btnCancel" runat="server"  Text="Cancel" />
</asp:panel>

</ContentTemplate>
</asp:UpdatePanel>


<cc1:UpdatePanelPopupExtender ID="UpdatePanelPopupExtender2" runat="server" TargetControlID="update2"
        OffsetX="2" OffsetY="2" CalloutColor="#7C6F57" CalloutBorderColor="Black" AutoPostBack="True" 
        OnClose="UpdatePanelPopupExtender2_Close"  />
    <!--------------UpdatePanelPopupExtender-------------------------->
    

<asp:UpdatePanel ID="update2" runat="server">
    <ContentTemplate>
        <asp:Panel ID="pnlEdit" runat="server" CssClass="modalPopup">
            <table>
                <tr>
                    <td>
                        Group Name:
                    </td>
                    <td>
                        <asp:TextBox ID="txtEditGroupName" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        Description:
                    </td>
                    <td>
                        <asp:TextBox ID="txtEditDescription" runat="server" TextMode="MultiLine" Rows="5"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        Public:
                    </td>
                    <td>
                        <asp:CheckBox ID="cbEditPublic" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Assign Courses:
                    </td>
                    <td>
                        <div style="overflow: scroll; height: 300px;">
                            <asp:CheckBoxList ID="cblEditAssignCourses" runat="server" DataTextField="CourseName" DataValueField="CourseID"></asp:CheckBoxList>
                        </div>
                    </td>
                </tr>
            </table>
            <asp:Button ID="btnSaveEdit" runat="server" Text="Save Changes" OnClick="EditGroup" />
            <asp:Button ID="btnSaveCancel" runat="server" Text="Cancel"  OnClick="CancelEditGroup" />
            
        </asp:Panel>
        </ContentTemplate>
        <triggers>
        <asp:AsyncPostBackTrigger ControlID="grdGroups" EventName="SelectedIndexChanged"></asp:AsyncPostBackTrigger>
    </triggers>
</asp:UpdatePanel>
</asp:Content>

